package org.ex;

/**
 * <p>Project: jse2303 - Enum2
 * <p>Powered by webrx On 2023-07-17 09:32:33
 * <p>描述：<p>
 *
 * @author webrx [webrx@126.com]
 * @version 1.0
 * @since 17
 */
public enum Enum2 {
    RED(100), GREEN(200), BLUE(300);

    private int code;

    Enum2(int code) {
        this.code = code;
    }

    public static Enum2 fromCode(int code) {
        Enum2 ee = null;
        for (Enum2 e : values()) {
            if (e.code == code) {
                ee = e;
                break;
            }
        }
        return ee;
    }

    public static Enum2 fromName(String n) {
        return valueOf(n);
    }

    public int toCode(Enum2 e) {
        return e.code;
    }
}
